import java.util.Arrays;

class Dog {
    //创建狗类
    //狗的属性
    public String name;//狗的名字
    public int age;
    public String color;

    //狗的行为（方法）
    public void barks() {
        System.out.println(name+":汪~汪~汪");
    }
    public void waf() {
        System.out.println(name+"：摇尾巴~~~");
    }
}


public class Test {
    //课堂代码练习：二维数组+类和对象

    public static void main2(String[] args) {
        //类的定义和使用
        Dog dog1 = new Dog();
        dog1.name = "黄耀逼";
        dog1.age = 19;
        dog1.color = "黄色";
        System.out.println("名字："+dog1.name);
        System.out.println("年龄："+dog1.age);
        System.out.println("颜色："+dog1.color);
        dog1.barks();
        dog1.waf();

        Dog dog2 = new Dog();
    }

    public static void main1(String[] args) {
        //1.二维数组定义
        int[][] arr1 = new int[][]{{1,2,3},{4,5,6}};
        System.out.println(arr1[0].length);
        System.out.println(arr1[1].length);
        System.out.println(arr1.length);

        int[][] arr2 = new int[3][];
        arr2[0] = new int[]{1,2,3,4};
        arr2[1] = new int[]{5,6,7};
        arr2[2] = new int[]{11,22,33,44,55};
        System.out.println(Arrays.toString(arr2[0]));
        //2.遍历方式1
        System.out.print("第一种遍历：");
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(arr1[i][j]+" ");
            }
        }
        System.out.println();
        //遍历2
        System.out.print("第二种遍历：");
        for (int i = 0; i < arr1.length; i++) {
            for (int j = 0; j < arr1[i].length; j++) {
                System.out.print(arr1[i][j]+" ");
            }
        }
        System.out.println();
        //遍历3
        System.out.print("第三种遍历：");
        for(int[] x:arr1) {
            for(int y:x) {
                System.out.print(y+" ");
            }
        }
    }
}
